package com.sevenGroup.pawnshop.controller;


import com.sevenGroup.pawnshop.Utils.Result;
import com.sevenGroup.pawnshop.controller.form.WarehouseStoreForm;
import com.sevenGroup.pawnshop.controller.form.WarehouseStoreForm1;
import com.sevenGroup.pawnshop.exception.sevenGroupException;
import com.sevenGroup.pawnshop.service.WarehouseStoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sevenGroup
 * @since 2022-02-16
 */
@RestController
@RequestMapping("/warehouseStore")
@Api(tags = "处理仓库门店中间表")
public class WarehouseStoreController {

    @Autowired
    private WarehouseStoreService warehouseStoreService;


    @PostMapping("delWarehouseByStoreId")
    @PreAuthorize("hasAnyAuthority('shopManage','boss')")
    @ApiOperation("根据门店id删除中间表数据")
    public Result delWarehouseByStoreId(@RequestBody WarehouseStoreForm warehouseStoreForm) throws sevenGroupException {
        warehouseStoreService.delWarehouseByStoreId(warehouseStoreForm);
        return Result.success(null);
    }

    @PostMapping("delWarehouseByList")
    @PreAuthorize("hasAnyAuthority('shopManage','boss')")
    @ApiOperation("根据门店id集合删除中间表数据")
    public Result delWarehouseByList(@RequestBody WarehouseStoreForm1 warehouseStoreForm1) throws sevenGroupException {
        warehouseStoreService.delWarehouseByList(warehouseStoreForm1);
        return Result.success(null);
    }
}

